import { Control } from 'react-keeper';
import { Boxs, NavBar, Group, Context } from 'saltui';
const { HBox, Box, VBox } = Boxs;
require('./PageWarndetail.styl');

const reactMixin = require('react-mixin');
const Actions = require('./actions');
const Store = require('./store');

class Warndetail extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            listdata: []
        };
        this.handleOnLeftClick = this.handleOnLeftClick.bind(this);
        this.handleClickNotice = this.handleClickNotice.bind(this);
    }
    handleOnLeftClick() {
        Control.go(-1)
    }
    handleClickNotice(){
       Actions.noticeParent(); 
    }
    render() {
        return (
            <div className="warndetail">
                <NavBar
                    className={this.state.className}
                    isShow={false}
                    title='预警详情'
                    onLeftClick={this.handleOnLeftClick.bind(this)}
                    onRightClick={Context.noop}
                    rightText=''
                />
                {this.state.listdata && this.state.listdata instanceof Array && this.state.listdata.map((item, index) => {
                    return (
                        <Group.List className="t-MT10 t-ML10 t-MR10">
                            <HBox className="warndetail-box">
                                <Box flex={2}>
                                    <span className="warndetail-box-title">{item.title}</span><span className="t-ML15 warndetail-box-content">{item.result}</span>
                                    <p className="t-MT10 t-MB13">{item.contentDesc}</p>
                                </Box>
                                <Box flex={1} className="t-FAR">
                                    <span className="t-MT15">{item.createDate}</span>
                                    <p className="t-MT10 t-MB15">{item.createUser}</p>
                                </Box>
                            </HBox>
                        </Group.List>
                    );
                })}
                <div className="t-FAC t-LH40 t-foot" onClick={this.handleClickNotice}>通知家长</div>
            </div>
        );
    }

    componentWillMount() {
    }

    componentDidMount() {
        Actions.fetch(Control.state.data)
    }

    componentWillReceiveProps(nextProps) {
    }

    shouldComponentUpdate(nextProps, nextState) {
        return true;
    }

    componentWillUpdate(nextProps, nextState) {
    }

    componentDidUpdate(prevProps, prevState) {
    }

    componentWillUnmount() {
    }
}

reactMixin.onClass(Warndetail, Reflux.connect(Store));

module.exports = Warndetail;
